package com.sunagy.demand.backend.controller.api;

import com.sunagy.demand.backend.VO.ResultVO;
import com.sunagy.demand.backend.exception.FileException;
import com.sunagy.demand.backend.utils.ResultVOUtil;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * File模块公共API
 *
 * @author eric.guo@ostengar.com
 * @version 1.0
 */
public class BaseFileApi extends BaseApi {

    @ExceptionHandler(FileException.class)
    @ResponseStatus(HttpStatus.OK)
    ResultVO fileExceptionHandler(FileException e) {
        if(e.getReason() != null && !"".equals(e.getReason())) {
            return ResultVOUtil.fail(e.getCode(),e.getReason());
        }
        return ResultVOUtil.fail("系统异常");
    }
}
